
TRIGGER PROCEDURE FOR DELETE OF PRH_HIST.

{mfdeclre.i }
define new shared work-table wf_old_prh_hist like prh_hist.

HK:
do:
    if can-find(first dt_mstr where dt_table = "prh_hist" and dt_type = "SYNC") then
        run CreateSyncFlag(input "DEL", input recid(prh_hist), input "prh_hist").

    if not can-find ( first dt_mstr where dt_table = "prh_hist" and dt_type = "DEL" ) then leave HK.
    
    if not can-find ( first wf_old_prh_hist ) then do:
        create wf_old_prh_hist.
        if recid(wf_old_prh_hist)= -1 then .
    end.
    
    buffer-copy prh_hist to wf_old_prh_hist no-error.

    for first dt_mstr no-lock where dt_table = "prh_hist" and dt_type = "DEL" :
    
    	run CreateDthist(input dt_table, input dt_field, input dt_type, input "", input "", 
        	input recid(prh_hist), input prh_hist.prh_nbr, input prh_hist.prh_receiver, input string(prh_hist.prh_line), input prh_hist.prh_element,
        	input "", input "", input "", input "") .
        	
    end.
end.

{hkdttrans.i}
